package quna;

import java.util.*;

/**
 * Created by lxy_920912 on 01/04/2017.
 */
public class Main2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        List<Hotel> list=  new ArrayList<>();
        for(int i = 0;i < n;i++){
            Hotel hotel = new Hotel(i,new int[5]);
            for(int j = 0;j < 5;j++){
                hotel.x[j] = scanner.nextInt();
                Arrays.sort(hotel.x);
            }
            list.add(hotel);
        }
        Comparator comparator = new compareList();
        Collections.sort(list,comparator);
        int flag = -1;
        for(int i = 0;i < n;i++){
            if(list.get(i).x[0] == 1){
                flag = i;
            }else{
                break;
            }
        }
        if(flag == -1){
            for(int i = n-1;i > 0;i--){
                System.out.print(list.get(i).no+" ");
            }
            System.out.print(list.get(0).no);
            System.out.println();
        }else{
            for(int i = 0; i <= flag;i++){
                System.out.print(list.get(i).no+" ");
            }
            for(int i = n;i > flag;i--){
             System.out.println(list.get(i).no+" ");
            }
        }

    }
}
